
package projectx.core.common.element;

import java.util.HashMap;
import java.util.Map;

final class ExternalCode {

    //--------------------------------------------------------------------------
    //   M E M B E R S
    //
    //--------------------------------------------------------------------------
    private final String    _keyCode;
    private final Map       _map;


    //--------------------------------------------------------------------------
    //   C O N S T R U C T O R S
    //
    //--------------------------------------------------------------------------
    ExternalCode( String keyCode ){

        _keyCode = keyCode;
        _map     = new HashMap();
    }


    //--------------------------------------------------------------------------
    //   M E T H O D S
    //
    //--------------------------------------------------------------------------
    String getKeyCode(){ return _keyCode; }

    String getDescription( String extCode, boolean isJp ){

        Description desc = (Description)_map.get( extCode );

        return ( desc == null ) ? null : desc.getDescription( isJp );
    }

    void put( String extCode, String jpDesc, String enDesc ){

        _map.put( extCode, new Description( jpDesc, enDesc ) );
    }


    //--------------------------------------------------------------------------
    //   I N N E R   C L A S S
    //
    //--------------------------------------------------------------------------
    private static class Description {

        private final String _jpDesc;
        private final String _enDesc;

        private Description( String jpDesc, String enDesc ){

            _jpDesc = jpDesc;
            _enDesc = enDesc;
        }

        private String getDescription( boolean isJp ){ return isJp ? _jpDesc : _enDesc; }
    }
}
